package com.cbg.enums;

/**
 * 移动方向枚举
 *
 * @author wangjuzhyeng
 * @since 2019-10-17
 */
public enum MoveDirectionEnum {

    TOP(0, "置顶"),
    UP(1, "上移"),
    DOWN(2, "下移"),
    LAST(3, "置底"),
    OTHER(99, "其他");

    /**
     * 移动方向标识
     */
    private int direction;
    /**
     * 说明
     */
    private String message;

    public int getDirection() {
        return direction;
    }

    public String getMessage() {
        return message;
    }

    MoveDirectionEnum(int direction, String message) {

        this.direction = direction;
        this.message = message;
    }

    /**
     * 根据direction获取枚举信息
     *
     * @param code direction
     * @return 对应枚举
     */
    public static MoveDirectionEnum getDirectionByCode(int code) {
        for (MoveDirectionEnum enums : MoveDirectionEnum.values()) {
            if (enums.getDirection() == code) {
                return enums;
            }
        }
        return null;
    }
}
